<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="/js/jquery-3.1.1.min.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css"
          integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
            crossorigin="anonymous"></script>

    <style type="text/css">
        body{
            font-family: 楷体;
            font-weight:bold;
        }
    </style>
</head>
<body>
<div class="container" style="width:20cm ">
    <!--startprint1-->

    <!--打印内容开始-->
    <div id=sty >
        <!--标头-->
        <div >
            <h1  style="text-align:center;font-weight: bold">中山市成栈饼家</h1>
        </div>
        <!--出货单和编号-->
        <div >
            <h2  style="position:relative; left:45%;display: inline;font-weight: bold">出货单</h2>
            <h2  style="display: inline;margin-left: 73%;font-weight: bold ">NO: [[${redPrintVo.no}]]</h2>
        </div>
        <!--客户和电话-->
        <div style="position: relative">
            <h3 style="font-family: 楷体;display: inline;font-size: 28px;">客户: [[${redPrintVo.clientName}]]</h3>
            <h3 style="font-family: 楷体;display: inline;position: absolute;left:58%;margin-top: 0px;font-size: 28px;">电话: [[${redPrintVo.phone}]] [[${redPrintVo.phonetwo}]]</h3>
        </div>
        <!--出货日期和地址-->
        <div style="position: relative">
            <h3 style="font-family: 楷体;display: inline;font-size: 28px;">出货日期:[[${redPrintVo.dispatchDate}]]</h3>
            <h3 style="font-family: 楷体;display: inline;position: absolute;left:58%;margin-top: 0px;font-size: 28px;">地址: [[${redPrintVo.city}]] [[${redPrintVo.town}]] </h3>
        </div>
        <!--表格-->
        <div >
            <table border="1px" style="width:100%;text-align: center;font-size: 24px">
                <tr style="height: 1cm">
                    <td style="width: 40%">产品名称</td>
                    <td>单位</td>
                    <td>数量</td>
                    <td>价钱</td>
                    <td style="width: 30%">金额</td>
                </tr>
                <tr style="height: 1cm"  th:each="l:${redPrintVo.itemList}">
                    <td style="width: 40%" th:text="${l.nameProduct}"></td>
                    <td th:text="${l.unitProduct}"></td>
                    <td th:text="${l.count}"></td>
                    <td th:text="${l.priceProduct}"></td>
                    <td style="width: 30%" th:text="${l.count}!=null?${l.priceProduct}*${l.count}:''"></td>
                </tr>
                <tr style="height: 1cm;text-align: left">
                    <td colspan="5" style="font-size: 24px">合计人名币:&nbsp;&nbsp;&nbsp;&nbsp;(大写)￥ [[${redPrintVo.sumPrice[0]}]] 万 &nbsp;[[${redPrintVo.sumPrice[1]}]] 仟 &nbsp;[[${redPrintVo.sumPrice[2]}]] 佰 &nbsp;[[${redPrintVo.sumPrice[3]}]] 什 &nbsp;[[${redPrintVo.sumPrice[4]}]] 元 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(小写)￥[[${redPrintVo.sumPriceNum}]]元</td>
                </tr>
                <tr style="height: 1cm;text-align: left;font-size: 24px">
                    <td colspan="5">备注: [[${redPrintVo.desc}]]</td>
                </tr>
            </table>
            <h3>地址: 中山市三角镇金三大道中72号</h3>
            <h3>电话: 0760-85542704</h3>
        </div>
    </div>
    <!--打印内容结束-->
    <!--endprint1-->
</div>
<!--打印内容结束-->
<!--endprint1-->
<button  onclick="preview(1)">开始打印</button>
<script language="javascript" th:inline="javaScript">
    $(function(){
        let oper =1;
        if (oper >= 10) {
            window.print();
        } else {
            bdhtml = window.document.body.innerHTML;//获取当前页的html代码
            sprnstr = "<!--startprint" + oper + "-->";//设置打印开始区域
            eprnstr = "<!--endprint" + oper + "-->";//设置打印结束区域
            prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr) + 18); //从开始代码向后取html
            prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));//从结束代码向前取html
            window.document.body.innerHTML = prnhtml;
            /*document.getElementById("WebBrowser").ExecWB(6,2);*/
            window.print();
            let url = "/system/orderhead/changestatu/" + [[${redPrintVo.no}]];
            $.getJSON(url, function (json) {
                console.log(json.msg);
                setTimeout(function(){ window.parent.$.modal.closeTab("/system/orderhead/print/"+[[${redPrintVo.no}]]); }, 200);
            })
        }
    })
</script>
</body>
</html>